﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SmarTypeWin;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        private StringBuilder text = new StringBuilder();
        String masterText;
        String oldMasterText;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if(e.Control && e.Alt && e.KeyCode == Keys.Back)
            {
                masterText = oldMasterText;
                textBox1.Text = masterText;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyUp(object sender, KeyEventArgs e)
        {
            
            if (e.KeyCode != Keys.Back && e.KeyCode != Keys.Enter)
            {
                text.Append(Convert.ToChar(e.KeyValue));
            }
            if (e.KeyCode == Keys.Space)
            {
                oldMasterText = masterText + text.ToString().ToLower();
                masterText += Analyser.getRightText(text.ToString().ToLower().Trim().ToCharArray()) + " ";
                
                text = new StringBuilder();
            }
            if (e.KeyCode == Keys.Back)
            {
                
            }

            textBox1.Text = masterText;
            textBox1.SelectionStart = textBox1.Text.Length;
        }
    }
}
